package com.chenchao.reflection;

import java.lang.annotation.*;

/**
 * @encoding : UTF-8
 * @Time : 2020/11/21 19:55
 * @Author : Chen Chao
 * @File : javaSE.com.chenchao.javareflection.Fish.java
 * @Software : IntelliJ IDEA
 * @since : 1.8
 */
@FishInfo(name="cat")
public class Fish {
    @FishFieldInfo(name="big")
    public String name;
    @FishFieldInfo(name="good")
    private int length;

    public Fish() {
    }

    public Fish(String name) {
        this.name = name;
    }

    private Fish(int length) {
        this.length = length;
    }
    public void grow(){
        System.out.println("我在成长");
    }
    public void grow(int length){
        System.out.println("我长长了"+length+"米");
    }
    private String secret(){
        return "我煮汤很好喝";
    }
    public static void show(){
        System.out.println("我是鱼类");
    }
    @Override
    public String toString() {
        return "Fish{" +
                "name='" + name + '\'' +
                ", length=" + length +
                '}';
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setLength(int length) {
        this.length = length;
    }
}
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@interface FishInfo{
    String name()default "fish";
    int age()default 18;
}

@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@interface FishFieldInfo{
    String name()default "colorful";
}